//
//  ViewController.m
//  UI_07homeworkNavigationAndGesture
//
//  Created by dllo on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"
#import "GestureImageView.h"

@interface ViewController ()<GestureImageViewDelegate>

@property(nonatomic , retain)NSArray *cocoArray;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    [self configNavigationItem];
    self.navigationController.navigationBarHidden = NO;
    
    
    [self creatPictures];
//    self.delegate = self;
}
// 第一个navigation
-(void)configNavigationItem{
    
    self.navigationItem.title = @"Pictures";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"go.png"] style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)];

}
// 右边Item的触发方法
-(void)rightAction:(UIBarButtonItem *)barItem{
    
    SecondViewController *secondVC = [[SecondViewController alloc]init];
    
    [self.navigationController pushViewController:secondVC animated:YES];
}


//创建图片数组
-(void)creatPictures{
    
    self.cocoArray = @[[UIImage imageNamed:@"aisi.jpg"], [UIImage imageNamed:@"family.jpg"], [UIImage imageNamed:@"leili.jpg"], [UIImage imageNamed:@"lufei.jpg"], [UIImage imageNamed:@"qiaoba.jpg"], [UIImage imageNamed:@"suolong.jpg"]];
    
//    for (int i = 0; i < 3; i++) {
//        for (int j = 0; j < 2; j++) {
//            GestureImageView *imageView = [[GestureImageView alloc]initWithFrame:CGRectMake(j * 30 + 40, i * 10 + 20, 90, 140)];
//            imageView.image = picArray[i];
//            [self.view addSubview:imageView];
//            [imageView release];
//            imageView.delegate = self;
//        }
//    }
    
    for (int i = 1; i < 7; i ++) {
        GestureImageView *imageView = [[GestureImageView alloc]init];
        
        // 添加tag值.
        imageView.tag = 1000 + i;
        
        SecondViewController *cccc = [[SecondViewController alloc]init];
        cccc.ccTag = imageView.tag;
        
        if (i < 4) {
            imageView.frame = CGRectMake(50, i * 150 + 15, 100, 150);
            
            
            
            
        }else {
            imageView.frame = CGRectMake(170, (i-3) * 150 + 15, 100, 150);
            
            
            
        }
        imageView.image = _cocoArray[i-1];
        imageView.delegate = self;
        [self.view addSubview:imageView];
        [imageView release];
        
    }

    
    
}


-(void)tapToJumpwithTag:(NSInteger)tag{
    SecondViewController *vc = [[SecondViewController alloc]init];
    vc.creazyArray = _cocoArray;
    
    vc.ccTag= tag;
    [self.navigationController pushViewController:vc animated:YES];
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
